package com.example.android.bluetoothchat;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.example.android.bluetoothchat.uitls.StringUtils;
import com.example.android.common.activities.SampleActivityBase;

/**
 * Created by Administrator on 2017/4/23 0023.
 */

public class PasswordActivity extends SampleActivityBase {

    private static final String PWD = "111111";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_password);

        findViewById(R.id.btn_server).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                login();
            }
        });
    }

    private void login() {
        EditText password = (EditText) findViewById(R.id.et_password);

        String pwd = password.getText().toString().trim();
        if (!TextUtils.isEmpty(pwd) && PWD.equals(pwd)) {
            ServerActivity.go(PasswordActivity.this);
        } else {
            Toast.makeText(this, R.string.input_right_password, Toast.LENGTH_SHORT).show();
        }
    }


    public static void go(Context context) {
        Intent intent = new Intent(context, PasswordActivity.class);
        context.startActivity(intent);
    }
}
